<link rel="stylesheet" type="text/css" href="<?php echo base_url()?>css/back_end/dropdown.css" />
<link rel="stylesheet" type="text/css" href="<?php echo base_url()?>css/back_end/Nav_HMenu.css" />
<script type="text/javascript" charset="utf-8" src="<?php echo base_url()?>javascripts/back_end/jquery-1.3.2.min.js"></script>
<script type="text/javascript" charset="utf-8" src="<?php echo base_url()?>javascripts/back_end/dropdown.js"></script>
<script language="javascript">
	$(document).ready(function(){
		$("#nav_menu > li").hover(function(){
			$("#nav_menu > li > ul").css('display','none');
			$(this).children("ul").css('display','block');
		});
	}); 
	
	$(document).ready(function() { 
		$("#nav_menu > li").mouseout(function(){
			$(this).children("ul").css('display','none');
			$(".active_active").children("ul").css('display','block');
			$("#nav_menu > li").removeClass("active_li");
			$("#nav_menu > li.active_active").addClass("active_li");
		}).mouseover(function(){
			$("#nav_menu > li > ul").css('display','none');
			$(this).children("ul").css('display','block');
			$("#nav_menu > li").removeClass("active_li");
			$(this).addClass("active_li");
		});
	});	
</script>
<?php 
	$logo	= $this->mod_lib->load_all('configs', 'logo, com_name, com_address', array(), 1, '', array());
?>
<div id="logo">
	<div style="float:left; margin-left: 20px;">
		<a style="float: left;" href="<?php echo base_url().'admins/admins/index_admin'?>">
			<img width="" height="" src="<?php echo base_url().'upload/logo/'.$logo[0]['logo']?>" title="<?php if (!empty($logo[0]['com_name'])) echo $logo[0]['com_name']?>" alt="<?php if (!empty($logo[0]['com_name'])) echo $logo[0]['com_name']?>">
		</a>
		<span style="float: left; color: #006600; padding-top: 30px; padding-left: 40px; font-size: 20px; font-weight: bold;" href="<?php echo base_url().'back_end/admin/index_admin'?>"><?php if (!empty($logo[0]['com_name'])) echo $logo[0]['com_name']?></span><br />
		<span style="color: #006600; padding-left: 40px; font-size: 12px; font-weight: bold;" href="<?php echo base_url().'back_end/admin/index_admin'?>"><?php if (!empty($logo[0]['com_address'])) echo $logo[0]['com_address']?></span>
	</div>
	<div id="logo-right">Xin chào, 
		<span class="black"><?php echo $_SESSION['username']." ";?></span> - 
		<a href="<?php echo base_url()?>" target="_blank">Homepage</a> - 
	 	<a href="<?php echo base_url()?>admins/admins/logout">Logout</a>
	</div>
	<div class="clear"></div>
</div>

<?php 
	if ($_SESSION['admin_id'] == 1){
	$menu_1		   = $this->mod_lib->load_all('admin_menu', '', array('status'=>1, 'cat_id'=>0), '', '', array('order'=>'ASC'));	
?>
<div class="dropdownmenu" style="margin-bottom: 30px;">
	<div class="wraper_nav_menu">	
		<ul id="nav_menu">
			<?php
				$i = 0; 
				foreach ($menu_1 as $m1){?>
				<?php
					$this->db->order_by('name', 'ASC');
					$menu_2		   = $this->db->get_where('admin_menu', array('status'=>1, 'cat_id !='=>0, 'cat_id'=>$m1['id']))->result_array();
				?>
				<li <?php foreach ($menu_2 as $mli) {if ($this->uri->segment(2) == $mli['link']){ echo 'class="active_li active_active"';}};?>>
					<?php if ($m1['link'] != 'admin/index_admin' && $m1['link'] != 'admin_contact'){?>
						<span style="cursor:pointer;"><?php echo $m1['name']?> <?php if (!empty($menu_2)) echo '&darr;';?></span>						
					<?php }else{?>
						<span style="cursor:pointer;" onclick="window.location.href='<?php echo base_url().$m1['link'].'/'.$m1['link']?>'"><?php echo $m1['name']?></span>
					<?php }?>
					<ul <?php foreach ($menu_2 as $mb) {if ($this->uri->segment(2) == $mb['link']){ echo 'style="display: block; background-color: F9F9F9;"';}};?>>
						<?php 
							$k=0;
							foreach ($menu_2 as $m2){
							if ($m1['id'] == $m2['cat_id']){?>
								<li><a <?php if ($this->uri->segment(2) == $m2['link']) echo 'style="text-decoration: underline; color: #ff6633;"'?> href="<?php echo base_url().$m2['module'].'/'.$m2['link']?>"><?php echo $m2 ['name'];?></a></li>
							<?php }?>
						<?php $k++;}?>						
					</ul>
				</li>
			<?php $i++;}?>
		</ul>
	</div>
</div>
<?php }else{
	$admin_id      = $_SESSION['admin_id'];
	$table_admin   = $this->db->get_where('admins', array('id' => $admin_id));
	$admin         = $table_admin->row_array();
	$admin_permiss = $this->db->get_where('admin_permiss', array('group_admin_id' => $admin['admin_group_id'], 'access' => '1'));	
?>
	<?php
		if($admin_permiss->num_rows() >0)
		{
	?>
	<div class="dropdownmenu" style="margin-bottom: 30px;">
		<div class="wraper_nav_menu">	
			<ul id="nav_menu">
				<?php
					foreach($admin_permiss->result_array() as $permiss)
					{
						$menu_1		   = $this->mod_lib->load_all('admin_menu', '', array('status'=>1, 'cat_id'=>0, 'id'=>$permiss['menu_admin_id']), '', '', array('order'=>'ASC'));	
						$i = 0; 
						foreach ($menu_1 as $m1){
							$menu_2		   = $this->db->get_where('admin_menu', array('status'=>1, 'cat_id !='=>0, 'cat_id'=>$m1['id']))->result_array();
						?>
						<li <?php foreach ($menu_2 as $mli) {if ($this->uri->segment(2) == $mli['link']){ echo 'class="active_li active_active"';}};?>>
							<?php if ($m1['link'] != 'admin/index_admin' && $m1['link'] != 'admin_contact'){?>
								<span style="cursor:pointer;"><?php echo $m1['name']?> <?php if (!empty($menu_2)) echo '&darr;';?></span>						
							<?php }else{?>
								<span style="cursor:pointer;" onclick="window.location.href='<?php echo base_url().'back_end/'.$m1['link']?>'"><?php echo $m1['name']?></span>
							<?php }?>
							<?php if (!empty($menu_2)){?>
								<ul <?php foreach ($menu_2 as $mb) {if ($this->uri->segment(2) == $mb['link']){ echo 'style="display: block;"';}};?>>
									<?php foreach ($menu_2 as $m2){
										if ($m1['id'] == $m2['cat_id']){?>
											<li><a <?php if ($this->uri->segment(2) == $m2['link']) echo 'style="text-decoration: underline; color: #ff6633;"'?> href="<?php echo base_url().'back_end/'.$m2['link']?>"><?php echo $m2 ['name'];?></a></li>
										<?php }?>
									<?php }?>						
								</ul>           
							<?php }?>
						</li>
					<?php $i++;}?>
				<?php }?>           
			</ul>
		</div>
	</div>
<?php }}?>